//
//  WJLoginRegisterView.m
//  BeDeJie
//
//  Created by jerry on 2017/1/28.
//  Copyright © 2017年 jerry. All rights reserved.
//

#import "WJLoginRegisterView.h"

@interface WJLoginRegisterView()

@property (weak, nonatomic) IBOutlet UIButton *loginBtn;
@property (weak, nonatomic) IBOutlet UIButton *registerBtn;

@end

@implementation WJLoginRegisterView

+ (instancetype) loginView {
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] firstObject];
}

+ (instancetype) registerView {
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass(self) owner:nil options:nil] lastObject];
}

//解决背景图片拉伸的问题
- (void) awakeFromNib {
    [super awakeFromNib];
    
    //登录的按钮背景图片
    [self resizableButtonBackground:self.loginBtn];
    //注册的按钮背景图片
    [self resizableButtonBackground:self.registerBtn];
}

-(void)resizableButtonBackground:(UIButton *)button {
    UIImage *image = button.currentBackgroundImage;
    //拉抻图片，和Android中的9path效果类似。
    image = [image stretchableImageWithLeftCapWidth:image.size.width * 0.5 topCapHeight:image.size.height * 0.5];
    //让按钮背景图片不要被拉伸
    [button setBackgroundImage:image forState:UIControlStateNormal];
}

- (IBAction)clickLoginBtn:(UIButton *)sender {
    WJLog(@"login btn click");
}

- (IBAction)clickRegisterBtn:(UIButton *)sender {
    WJLog(@"register btn click");
}

@end
